var fs = require('fs');
var csv2 = require('csv2');
var through2 = require('through2');
var all = [];

fs.createReadStream('../assets/data.csv')
  .pipe(csv2())
  .pipe(through2.obj(function (chunk, enc, callback) {
    var data = {
      id: chunk[0],
      name: chunk[1],
      price: chunk[2]
    };
    this.push(data);
    callback()
  }))
  .on('data', function (data) {
    all.push(data)
  })
  .on('end', function () {
    console.log(all);
  });
